package view;

import java.awt.BorderLayout;

import javax.swing.Action;
import javax.swing.JFrame;
import javax.swing.JScrollPane;

import model.State;

import view.AboutAction;
import view.CloseAction;

/**
 * The main GUI view.
 * @author Sarah George
 * @version Autumn 2012
 */
public class GUIView {
	
	/**
	 * Field to hold the current state of the system.
	 */
	private State my_state;
	
	/**
	 * Constructor for the main gui view.
	 * @param the_state the current state of the system.
	 */
	public GUIView(State the_state) {
		my_state = the_state;
	}
	
	/**
	 * Starts the main gui view of the program.
	 */
	public void start() {
		
		final UserMenus menus = new UserMenus();
		final RolePanel role_panel = new RolePanel(my_state);
		final UserPanel user_panel = new UserPanel(my_state);
		final JFrame gui_frame = new JFrame("Main Program");

		final Action[] file_actions = {
			new LogoutAction(my_state, gui_frame),
			new CloseAction(gui_frame)
		};
		menus.createFileMenuBarButton(file_actions);

		final Action[] help_actions = {
			new AboutAction(),
			//This is placeholder for other information.
		};
		for (Action a : help_actions) {
			menus.createHelpMenuBarButton(a);
		}


		gui_frame.setJMenuBar(menus);
	    gui_frame.add(role_panel, BorderLayout.WEST);
	    gui_frame.add(user_panel, BorderLayout.EAST);
		gui_frame.setResizable(true); 
		gui_frame.pack();
		gui_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);   
		gui_frame.setLocationRelativeTo(null);
		gui_frame.setVisible(true);
	}
}//End class GUIView.